<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter"%>
<%@page import="org.springside.modules.security.springsecurity.SpringSecurityUtils"%>
<%@page import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"%>
<%@include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@include file="/common/meta.jsp" %>
	<title>SubSpringSide</title>
	<link rel="stylesheet" href="${ctx }/css/common.css"/>
	<script type="text/javascript" src="${ctx }/js/jquery.js"></script>
	<script type="text/javascript" src="${ctx }/js/validate/jquery.validate.js"></script>
	<script type="text/javascript" src="${ctx }/js/validate/messages_cn.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#loginForm").validate();
		});
	</script>
</head>

<body>

<h2>Spring-Security登录(整合Jcaptcha)</h2><hr/>
<!-- 方式一：  -->
<%
	//if (session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY) != null) {
%>
<!-- 
<div class="error flash">登录失败，请重试.</div>
-->
<%
//}
%>

<!-- 方式二： -->
<%if("1".equals(request.getParameter("error"))){%>
	<div class="error flash">验证码不正确.</div>
<%}else if("2".equals(request.getParameter("error"))){%>
<div class="error flash">用户名或密码不正确.</div>
<%}else if("3".equals(request.getParameter("error"))){ %>
<div class="error flash">此帐号已从别处登录.</div>
<%}else{ %>
<div class="notice flash">您好,<%=SpringSecurityUtils.getCurrentUserName() %>从<%=SpringSecurityUtils.getCurrentUserIp() %>登录.</div>
<%} %>
<form id="loginForm" method="post" action="./j_spring_security_check">
	<div style="width: 100%;height: 300px;border: 1px solid gray;margin: 0;padding: 0;">
		<ul style="height: 100%;width: 100%">
			<li><span>用户名:</span><span><input accesskey="1" type="text" id="j_username" name="j_username" <s:if test="not empty param.error"> value="<%=session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"</s:if> class="required"/></span></li>
			<li><span>密&emsp;码:</span><span><input accesskey="2" type="password" id="j_password" name="j_password" class="required"/></span></li>
			<li><span><input type="reset" value="重置" accesskey="3"/></span><span><input type="submit" value="提交" accesskey="4"/></span><input type="checkbox" name="_spring_security_remember_me" id="_spring_security_remember_me" accesskey="5" /><label for="_spring_security_remember_me" style="cursor: pointer;" accesskey="6">两周内记住我</label></li>
			<li><span><input type="text" id="j_captcha" name="j_captcha" class="required"/></span><span><img src="${ctx }/jcaptchaII.jpg"/></span></li>
		</ul>
	</div>
</form>
<h6>(管理员：admin/admin,用户：user/user)</h6>
<h4><a href="${ctx }">&lt;&lt;返回首页</a>|<a href="${ctx}/j_spring_security_logout">退出登录</a></h4>

</body>
</html>